Repository navigation
fix(id-web): validate shell contract field specs - #4238
Conversation
…queue/5412-2657-shell-contract-validation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 50 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c2319ed9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| min: raw.min as number | undefined, | ||
| max: raw.max as number | undefined, | ||
| maxBytes: raw.max_bytes as number | undefined, | ||
| allowed: raw.enum as string[] | undefined, |
There was a problem hiding this comment.
Validate constraint types before accepting field specs
When a contract contains a malformed constraint such as chat.text: {"type":"string","enum":7}, the new parseShellContract accepts it because this assertion performs no runtime validation. Passing the returned contract to checkClientFrame with a chat message then throws TypeError: field.allowed.includes is not a function, bypassing the failed-check handling and preventing Conformance from recording a violation. Validate the constraint types during parsing, particularly that enum is an array of strings, so successfully loaded contracts cannot reach this failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 04af08e: parseField now validates constraint types at load — enum must be an array of strings, and min/max/max_bytes must be finite numbers — so parseShellContract rejects a malformed spec with the frame.field prefix instead of letting checkValue throw later. Regression tests added ("rejects malformed constraint values when loading a contract"); bun run test -- src/world-contract.test.ts passes 21/21 on the laptop.
parseField accepted malformed constraints (e.g. enum: 7) unchecked, so a loaded contract could make checkValue throw (allowed.includes) instead of recording a violation. Reject non-finite min/max/max_bytes and non-string-array enum at parse time; regression tests cover both. Addresses Codex P2 on PR #4238.
Summary
Conformancerecords a violation instead of throwing.view_revision.Evidence
main,bun run test -- src/world-contract.test.ts— 3 existing failures from missingview_revision.After: same command — 20/20 tests pass.
bun run typecheckstill reports the pre-existing nullability error atsrc/image-upload.test.ts:423, reproduced on cleanmain.git diff --check— pass.Merge Danger
Door: two-way
Blast Radius: low — checker behavior and its tests only; no wire-format changes.
Closes #2657.
Need help on this PR? Tag
@codesmith-botwith what you need.